-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow custom @-rules to execute custom functions #2852
Conversation
I'm actually against this: if I'm not mistaken this feature is already supported via visitor plugins (I can't test it right now, but I suspect it's about 20-40 lines of code to map |
@seven-phases-max It isn't another plugin format. Plugins are declared the same way. It's just allowing the @-rule as a stand-in for replacement, with the arguments sent to JS, just like custom functions do. It behaves the same, where @-rules / functions pass through unchanged if they don't match a registered function. The only difference is that the arguments are always the same. That said.... offering plugin templates for specific types of use cases is not unreasonable. I've actually been working on a "universal" plugin template for Less. That is, one that can unify the two separate plugin formats and be loaded either way. Currently, both formats are mutually incompatible, and even have opposite program flows (plugin A "attaches" itself to Less, plugin B gets attached by Less). Buuuuut there may be a way to bridge the gap. |
Oh, now I remember the justification for this over some kind of visitor plugin. You can't currently call the latter with
What if I focus on this:
That might be better anyway because it focuses on making some of the core pieces easier to use, rather than adding something to functions. Sound better? |
Yes, otherwise if accepted, this justification would literally mean "abandon plugins" (except functions, but "easy functions" were not really the only and the main goal of all those efforts). I've put additional details on "plugin unification" at #17. |
Closing this pull request per discussion. |
This is a small but powerful extension to custom functions per the discussion here: less/less-meta#10. Like regular functions, it allows you to intercept at-rules and see if there's a match in the function registry for that directive (at-rule). And like functions, if there is no match, it allows the directive to pass through as-is.
This allows you to do powerful stuff like: